{template 'common/header'}
	<ul class="nav nav-tabs">
		<li class="active"><a href="{php echo create_url('account/post')}">添加公众号</a></li>
		<li><a href="{php echo create_url('account/display')}">管理公众号</a></li>
	</ul>
	<div class="main">
		<form action="" method="post" class="form-horizontal form">
		<input type="hidden" name="id" value="{$wechat['weid']}" />
			{if empty($id)}
			<h4>添加公众帐号</h4>
			{else}
			<h4>设置公众号</h4>
			{/if}
			<table class="tb">
				<tr>
					<th><label for="">公众号名称</label></th>
					<td>
						<input type="text" name="name" class="span6" value="{$wechat['name']}" autocomplete="off">
						<span class="help-block">您可以给此公众号起一个名字, 方便下次修改和查看.</span>
					</td>
				</tr>
				<tr>
					<th><label for="">公众平台帐号</label></th>
					<td>
						<input type="text" name="account" class="span6" value="{$wechat['account']}" autocomplete="off" />
						<span class="help-block">公众平台帐号,可以为空</span>
					</td>
				</tr>
				<tr>
					<th><label for="">公众号类型</label></th>
					<td>
						<select name="type" id="type" onchange="verifyGen()">
							<option value="1" {if $wechat['type'] == 1} selected{/if}>微信公众平台</option>
							<option value="2" {if $wechat['type'] == 2} selected{/if}>易信公众平台</option>
						</select>
						<span class="help-block">您可以给此公众号起一个名字, 方便下次修改和查看.</span>
					</td>
				</tr>
				<tr>
					<th>公众平台主页</th>
					<td>
						<input type="text" name="homepage" class="span6" value="{$wechat['homepage']}" autocomplete="off"/>
						<div class="help-block">请填写微信易信等公众平台后台的主页链接</div>
					</td>
				</tr>
				{if !empty($id)}
				<tr>
					<th style="color:red">接口地址</th>
					<td>
						<input type="text" class="span6" value="{$_W['siteroot']}api.php?hash={$wechat['hash']}" readonly="readonly" autocomplete="off"/>
						<div class="help-block">设置“公众平台接口”配置信息中的接口地址</div>
					</td>
				</tr>
				<tr>
					<th style="color:red">公众平台Token</th>
					<td>
						<input type="text" name="wetoken" class="span6" value="{$wechat['token']}" readonly="readonly" /> <a href="javascript:;" onclick="tokenGen();">生成新的</a>
						<div class="help-block">与公众平台接入设置值一致，必须为英文或者数字，长度为3到32个字符. 请妥善保管, Token 泄露将可能被窃取或篡改平台的操作数据.</div>
					</td>
				</tr>
				{/if}
				<tr>
					<th>公众号AppId</th>
					<td>
						<input type="text" name="key" class="span6" value="{$wechat['key']}" autocomplete="off"/>
						<div class="help-block">请填写公众平台后台的AppId</div>
					</td>
				</tr>
				<tr>
					<th>公众号AppSecret</th>
					<td>
						<input type="text" name="secret" class="span6" value="{$wechat['secret']}" autocomplete="off"/>
						<div class="help-block">请填写公众平台后台的AppSecret, 只有填写这两项才能管理自定义菜单</div>
					</td>
				</tr>
				{if !empty($wechat['username'])}
				<tr>
					<th>二维码</th>
					<td>
						<img class="img-polaroid" src="{$_W[attachurl]}/qrcode_{$wechat['weid']}.jpg?weid={$wechat['account']}" width="150" />
					</td>
				</tr>
				{/if}
				{if !empty($wechat['username'])}
				<tr>
					<th>头像</th>
					<td>
						<img class="img-polaroid" src="{$_W[attachurl]}/headimg_{$wechat['weid']}.jpg?weid={$wechat['account']}" width="85" />
					</td>
				</tr>
				{/if}
			</table>
			<h4>设置帐号<small>设置用户名密码后，程序会自动采集您的公众号相关信息。</small></h4>
			<table class="tb">
				<tr>
					<th><label for="">公众登录用户</label></th>
					<td>
						<input type="text" name="wxusername" id="username" class="span6" value="{$wechat['username']}" autocomplete="off" onblur="verifyGen()" />
						<span class="help-block">请输入你的公众平台用户名</span>
					</td>
				</tr>
				<tr>
					<th><label for="">公众登录密码</label></th>
					<td>
						<input type="password" name="wxpassword" class="span6" value="" autocomplete="off"  />
						<span class="help-block">请输入你的公众平台密码</span>
					</td>
				</tr>
				<tr>
					<th><label for="">登录验证码</label></td>
					<td>
						<input type="text" name="verify" class="txt grid-1 alpha pin" value="" autocomplete="off" />
						<span class="help-inline"><img src="" id="imgverify"> <a href="javascript:;" onclick="verifyGen()">换一张</a></span>
					</td>
				</tr>
				<tr>
					<th></th>
					<td>
						<label class="checkbox inline"><input type="checkbox" name="islogin" value="1" checked="checked" /> 是否验证登录</label>
						<div class="help-inline">&nbsp;勾选此选项后，提交后将验证您的公众平台帐号。如果有任何异常信息，请取消此选项。</div>
					</td>
				</tr>
				{if !empty($wechat['username'])}
				<tr>
					<th></th>
					<td>
						<a href="{php echo create_url('account/sync', array('id' => $wechat['weid']))}">同步公众平台帐号信息</a>
						<div class="help-block">填写公众号帐号密码后，如果发现信息没有同步成功，请点击此选项进行手动同步。</div>
					</td>
				</tr>
				{/if}
				<tr>
					<th></th>
					<td>
						<input name="submit" type="submit" value="提交" class="btn btn-primary span3" />
						<input type="hidden" name="token" value="{$_W['token']}" />
					</td>
				</tr>
			</table>
		</form>
	</div>
<script type="text/javascript">
<!--
	var codeurl = {'1':'https://mp.weixin.qq.com/cgi-bin/verifycode', '2':'https://plus.yixin.im/captcha'};
	function verifyGen() {
		if ($('#username').val()) {
			var type = $('#type').val() ? $('#type').val() : 1;
			$('#imgverify').attr('src', codeurl[type] + '?username='+$('#username').val()+'&r='+Math.round(new Date().getTime()));
		} else {
			//alert('请先输入微信公众平台用户名');
		}
	}
//-->
</script>
{template 'common/footer'}
